using System.Text.Json;
using RSCore;
using RSCore.Files;

namespace _ReplaceString_;

public record struct PackageID(string Mod, string Name, PackageType Type)
{
	private static Dictionary<PackageID, BuildFile> cache = new();

	public readonly BuildFile LoadPackage()
	{
		if (cache.TryGetValue(this, out var result))
		{
			return result;
		}

		if (Type == PackageType.Test)
		{
			using FileStream stream = File.OpenRead($"{ModHelper.PackagePath}/{Mod}/{Name}.json");
			var build = JsonSerializer.Deserialize<BuildFile>(stream)!;
			return cache[this] = build;
		}

		throw new NotImplementedException();
	}
}